using UnityEngine;
using UnityEngine.UI;

[RequireComponent(typeof(Graphic))]
public class UIShader_Wobble : MonoBehaviour
{
	public int frameDelay = 5;

	public float wobbleAmount = 5f;

	private Graphic graphic;

	private int currentFrame;

	private Vector2 seed;

	private void Awake()
	{
		graphic = GetComponent<Graphic>();
		seed = new Vector2(Random.value * 1000f, Random.value * 1000f);
	}

	private void Update()
	{
		currentFrame++;
		if (currentFrame % frameDelay == 0)
		{
			seed = new Vector2(Random.value * 1000f, Random.value * 1000f);
		}
		Material materialForRendering = graphic.materialForRendering;
		materialForRendering.SetVector("_WobbleSeed", seed);
		materialForRendering.SetFloat("_WobbleAmount", wobbleAmount);
	}
}
